package com.yjc.springcloud.service.Impl;

import com.yjc.springcloud.service.IMessageProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import java.util.UUID;

/**
 * @author shkstart
 * @create 2022-08-07 23:20
 */
@EnableBinding(Source.class)
public class IMessageProviderImpl implements IMessageProvider {

    @Autowired
    MessageChannel output;

    @Override
    public String sendMsg() {
        String res = UUID.randomUUID().toString();
        output.send(MessageBuilder.withPayload(res).build());
        System.out.println("发送消息：" + res);
        return null;
    }
}
